/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package polandballgame;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;

/**
 *
 * @author POed
 */
public class StatusBar extends JPanel {
    
    // data:
    Engine engine;
    
    JLabel health;
    JLabel armor;
    JLabel ammo;
    JLabel healthLabel;
    JLabel armorLabel;
    JLabel ammoLabel;
    
    public StatusBar() {
        
        super();
        
        this.setLayout(null);
        
        // labels:
        Font font = new Font("Verdana-Bold", Font.PLAIN, 18);
        Color color = new Color(154, 154, 154);
        Dimension labelSize = new Dimension(240, 20);
        
        healthLabel = new JLabel("HEALTH");
        healthLabel.setLocation(300, 50);
        healthLabel.setSize(labelSize);
        healthLabel.setHorizontalAlignment(JLabel.CENTER);
        healthLabel.setFont(font);
        healthLabel.setForeground(color);
        this.add(healthLabel);
        
        armorLabel = new JLabel("ARMOR");
        armorLabel.setLocation(720, 50);
        armorLabel.setSize(labelSize);
        armorLabel.setHorizontalAlignment(JLabel.CENTER);
        armorLabel.setFont(font);
        armorLabel.setForeground(color);
        this.add(armorLabel);
        
        ammoLabel = new JLabel("MINERALS");
        ammoLabel.setLocation(40, 50);
        ammoLabel.setSize(labelSize);
        ammoLabel.setHorizontalAlignment(JLabel.CENTER);
        ammoLabel.setFont(font);
        ammoLabel.setForeground(color);
        this.add(ammoLabel);
        
        // values:
        font = new Font("Verdana-Bold", Font.PLAIN, 38);
        color = new Color(156, 35, 36);
        labelSize = new Dimension(240, 40);
        
        health = new JLabel("");
        health.setLocation(300, 4);
        health.setSize(labelSize);
        health.setHorizontalAlignment(JLabel.CENTER);
        health.setFont(font);
        health.setForeground(color);
        this.add(health);
        
        armor = new JLabel("");
        armor.setLocation(720, 4);
        armor.setSize(labelSize);
        armor.setHorizontalAlignment(JLabel.CENTER);
        armor.setFont(font);
        armor.setForeground(color);
        this.add(armor);
        
        ammo = new JLabel("");
        ammo.setLocation(40, 4);
        ammo.setSize(labelSize);
        ammo.setHorizontalAlignment(JLabel.CENTER);
        ammo.setFont(font);
        ammo.setForeground(color);
        this.add(ammo);
    }
    
    public void setHeroStats(Countryball hero) {
    
        health.setText(hero.currentHP + "%");
        health.setLocation(300, 4);
        armor.setText(hero.currentArmor + "%");
        armor.setLocation(720, 4);
        
        if (hero.type == 7) {
            Polandball poland = (Polandball)hero;
            ammo.setText(Integer.toString(poland.minerals));
        }
        else {
            ammo.setText("N/A");
        }
        ammo.setLocation(40, 4);
    }
    
    // methods:
    public void setEngine(Engine anEngine) {
        
        engine = anEngine;
    }
    
    @Override public void paintComponent(Graphics context) {
        
        Color color = new Color(90, 90, 90);
        context.setColor(color);
        context.fillRect(0, 0, this.getWidth(), this.getHeight());
    }
}
